package com.zbl.zblproject.erp.controller;

import com.zbl.zblproject.core.entity.Result;
import com.zbl.zblproject.core.utils.ResultUtil;
import com.zbl.zblproject.erp.service.ErpCategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author youlanqiang
 * @version 1.0
 * @date 2018/10/9
 */
@RestController
@Api(value = "产品分类接口", tags = {"产品分类接口"})
@RequestMapping("/erp-category")
public class ErpCategoryController {

    @Autowired
    private ErpCategoryService erpCategoryService;

    @GetMapping("/all")
    @ApiOperation("获取所有的产品分类")
    public Result all(){
        System.out.println("test /erp-category all");
        System.out.println("test /erp-category all");

        return ResultUtil.success("成功!", erpCategoryService.categories());
    }


    @GetMapping("/list")
    @ApiOperation("获取所有的产品LIST")
    public Result list(){
        return ResultUtil.success("成功!", erpCategoryService.list());
    }

    @GetMapping("/{parentId}")
    @ApiOperation("查询parentId相等的分类")
    public Result childrenList(@ApiParam("分类ID") @PathVariable int parentId){
        return ResultUtil.success("成功!", erpCategoryService.categories(parentId));
    }

}
